<?php
function connection(){
		$myhost="localhost";
		$myuser="root";
		$mypass="";
		$mydb="elearning";	
	     /* Connecting, selecting database */
	     mysql_connect($myhost, $myuser, $mypass)
		 or die("Could not connect : " . mysql_error());
	     /*print "Connected successfully";*/
	     mysql_select_db($mydb) or die("Could not select database");
		 
}


function validateRoomName($rName){
		//if it's NOT valid
		if(strlen($rName) < 4)
			return false;
		//if it's valid
		else
			return true;
	}

	function validateRep($repName){
		//if it's NOT valid
		if(strlen($repName) < 4)
			return false;
		//if it's valid
		else
			return true;
	}
	function validateOrig($origName){
		//if it's NOT valid
		if(strlen($origName) < 4)
			return false;
		//if it's valid
		else
			return true;
	}
	function validateSecName($secName){
		//if it's NOT valid
		if(strlen($secName) < 4)
			return false;
		//if it's valid
		else
			return true;
	}
	function validateFname($fname){
		//if it's NOT valid
		if(strlen($fname) < 4)
			return false;
		//if it's valid
		else
			return true;
	}
	function validateLname($lname){
		//if it's NOT valid
		if(strlen($lname) < 4)
			return false;
		//if it's valid
		else
			return true;
	}
	function validateMname($mname){
		//if it's NOT valid
		if(strlen($mname) < 4)
			return false;
		//if it's valid
		else
			return true;
	}
	
	function validateSn($secName){
		//if it's NOT valid
		if(strlen($secName) < 4)
			return false;
		//if it's valid
		else
			return true;
	}
	function validateRm($rmName){
		//if it's NOT valid
		if(strlen($rmName) < 4)
			return false;
		//if it's valid
		else
			return true;
	}
	function validateSecAd($secAd){
		//if it's NOT valid
		if(strlen($secAd) < 4)
			return false;
		//if it's valid
		else
			return true;
	}
		function validateSex($sex){
		//if it's NOT valid
		if ($sex == "male" || $sex == "female") {
    		return true;
		} else {
   			return false;
		}
	}
	function validateEmail($email){
		return ereg("^[a-zA-Z0-9]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$", $email);
	}
	function validateDOB($dob){
		if (preg_match("/^(0[1-9]|[12][0-9]|3[01])[\/](0[1-9]|1[012])[\/](19|20)\d\d$/", $dob)) {
    		return true;
		} else {
   			return false;
		}
	
	}

	
?>